<template>
  <div>
    <van-nav-bar title="分类商品" left-arrow   @click-left="onClickLeft"/>
    <Popul :populList="populList" v-if="populList.length > 0"></Popul>
    <van-empty description="没有找到商品" v-else/>
  </div>
</template>

<script>
import Popul from "../../components/home/Popul";
export default {
  data() {
    return {
      c_id: 0,
      populList: [],
    };
  },
//   props:["populList"],
  created() {},
  components: {
    Popul
  },
  mounted() {
    //页面传递过来的分类id
    this.c_id = this.$route.params.cid;
    this.popul();
  },
  methods: {
    popul() {
      this.$axios
        .get("https://api.it120.cc/small4/shop/goods/list")
        .then((res) => {
          console.log(res);
          let data = res.data.filter((item) => {
            return item.categoryId == this.c_id             //判断当前商品是否等于传递过来的分类ID
          });
          this.populList = data
        });
    },
    onClickLeft(){
        this.$router.go(-1)
    }
  },
};
</script>

<style scoped lang="less">

</style>
